﻿using System.ComponentModel;

namespace QuizzMe.Model
{
    /// <summary>
    /// Wrapper for option in a "checkbox" control
    /// </summary>
    public class CheckableText : INotifyPropertyChanged
    {
        private bool _selected;
        private string _text;

        /// <summary>
        /// Is the option selected ?
        /// </summary>
        public bool Selected
        {
            get { return _selected; }
            set
            {
                if (_selected != value)
                {
                    _selected = value;
                    OnPropertyChanged("Selected");
                }
            }
        }

        /// <summary>
        /// Option label
        /// </summary>
        public string Text
        {
            get { return _text; }
            set
            {
                if (_text != value)
                {
                    _text = value;
                    OnPropertyChanged("Text");
                }
            }
        }

        public CheckableText(string text)
        {
            Text = text;
            Selected = false;
        }

        // INotifyPropertyChanged
        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string element)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(element));
        }
    }
}
